package com.campus_assistant.service.db1;

import com.alibaba.fastjson.JSON;
import com.campus_assistant.mapper.db1.CoursesMapper;
import com.campus_assistant.pojo.db1.Courses;
import com.campus_assistant.pojo.db1.Student;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class CoursesServiceImpl implements CoursesService {
    @Autowired
    private CoursesMapper coursesMapper;
    @Autowired
    private RestHighLevelClient restHighLevelClient;
    @Override
    public int addCourses(Courses courses) {

        return coursesMapper.addCourses(courses);
    }

    @Override
    public int deleteCourses(int id) {

        return coursesMapper.deleteCourses(id);
    }

    @Override
    public int updateCourses(Courses courses) {

        return coursesMapper.updateCourses(courses);
    }

    @Override
    public List<Courses> selectAll() {
        return coursesMapper.selectAll();
    }

    @Override
    public int getIdByCourseNameAndTeacherName(String courseName, String teacherName) {
        return coursesMapper.getIdByCourseNameAndTeacherName(courseName,teacherName);
    }

    @Override
    public List<Courses> getCoursesByTeacherName(String teacherName) {
        return coursesMapper.getCoursesByTeacherName(teacherName);
    }

    @Override
    public List<String> getTeacherNameByCoursesName(String coursesName) {
        return coursesMapper.getTeacherNameByCoursesName(coursesName);
    }

    @Override
    public List<Courses> getCoursesByName(String name) {
        return coursesMapper.getCoursesByName(name);
    }

    @Override
    public Courses getCoursesById(int id) {
        return coursesMapper.getCoursesById(id);
    }


}
